class Solution(object):
    def brokenCalc(self, startValue, target):
        c = 0
        while target > startValue:
            if target % 2 == 1:
                target += 1
                c += 1
            else:
                if target // 2 >= startValue:
                    target = target // 2
                    c += 1
                else:
                    c += min(2 * startValue - target + 1, 1 + startValue - target // 2)
                    target = startValue
        return c + startValue - target

data = Solution()
startValue = 2
target = 3
print(data.brokenCalc(startValue, target))
startValue = 5
target = 8
print(data.brokenCalc(startValue, target))
startValue = 3
target = 10
print(data.brokenCalc(startValue, target))